import { Req, type Resp } from '@/utils/request'

export interface LoginParam {
  username: string
  password: string
}

export interface LoginResult {
  role: string
  user_id: number
  last_login: string
  last_login_ip: string
  nickname: string
  token: string
}

// 登录
export function login(body: LoginParam): Promise<Resp<LoginResult>> {
  return Req.$post<LoginResult>('/auth/login', body)
}

// 获取用户信息
export function getUserProfile(): Promise<Resp<UserProfile>> {
  return Req.$get<UserProfile>('/user/profiles')
}

// 当前用户菜单
export function getUserMenu(): Promise<Resp<Menu[]>> {
  return Req.$get<Menu[]>('/system/menu/userMenu')
}
